home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / graphics / screen_jaeger / source / prog.c < prev    next >
C/C++ Source or Header  |  1994-11-17  |  19KB  |  829 lines

  1. /*************************************************************\
  2.  *                     SCREEN JAEGER                         *
  3.  *                     ~~~~~~ ~~~~~~                         *
  4.  *                                                           *
  5.  *       'Jaeger' - German word meaning HUNTER               *
  6.  *                  I'm not German, but I like the word      *
  7.  *                                                           *
  8.  *               Written by Syd L. Bolton                    *
  9.  *       ©1991 Legendary Design Technologies Inc.            *
  10.  *                                                           *
  11.  *         Compiled using Manx Aztec C (tm) V5.0             *
  12.  *                                                           *
  13.  *      Started:       Date:  May 13, 1991  Time: 18:55:00   *
  14.  *      Version: 1.00  Date: July 12, 1991  Time: 00:17:00   *
  15.  *      Version: 1.01  Date: July 16, 1991  Time: 12:30:00   *
  16. \*************************************************************/
  17.  
  18. #include <intuition/intuition.h>
  19. #include <intuition/intuitionbase.h>
  20. #include <exec/memory.h>
  21. #include <exec/execbase.h>
  22. #include <graphics/gfx.h>
  23. #include <graphics/gfxbase.h>
  24. #include <math.h>
  25. #include <iff.h>
  26.  
  27. long *IntuitionBase,*GfxBase,*IFFBase;
  28. extern struct ExecBase *SysBase;
  29. struct MemHeader *mh;
  30. struct BitMap bm;
  31. struct Screen *Screen,*MainScreen;
  32. struct Window *Window,*MessageWindow,*InfoWindow;
  33. struct ViewPort *ViewPort,*vport;
  34. struct RastPort *rport,*mrport,*irport;
  35. UWORD colortable[32];
  36. long upper[2],lower[2],xbody,ybody;
  37. long FOffset[6];
  38. PLANEPTR PlanePtr[6];
  39.  
  40. #include "screen.h"
  41. #include "main.h"
  42. #include "message.h"
  43. #include "info.h"
  44.  
  45. #define CHIP 0
  46. #define FAST 1
  47.  
  48. int num_bitplanes=1,fine=0,direction,plane=0,copy=0,swap=0;
  49. int width,height,NormalRows;
  50. int type=CHIP;
  51. int XOffset=0,YOffset=0;
  52. int overscan=0;
  53.  
  54. long offset=32768;
  55.  
  56. main()
  57. {
  58. int i,exit_prog=0;
  59. struct IntuiMessage *message;
  60. ULONG class;
  61.  
  62. openlibraries();
  63. setup();
  64. show_plane(2,1);
  65.  
  66. do {
  67.     WaitPort(Window->UserPort);
  68.                   while( (message = (struct IntuiMessage *)
  69.                          GetMsg(Window->UserPort) ) != NULL)
  70.                   {
  71.                       class = message->Class;
  72.                       ReplyMsg(message);
  73.      
  74.               if ( class == GADGETUP) exit_prog=option(message);
  75.               if ( class == GADGETDOWN && fine==0) holdit(message);
  76.               if ( class == VANILLAKEY) key(message);
  77.         }
  78.       } while (exit_prog==0);
  79.  
  80. closestuff(0);
  81. }
  82.  
  83. #include "pointer.h"
  84.  
  85. key(message)
  86. struct IntuiMessage *message;
  87. {
  88. int c;
  89.  
  90. c=message->Code;
  91.  
  92. switch (c) {
  93.     case 'b':
  94.     case 'B': ScreenToFront(Screen);
  95.           break;
  96.  
  97.     case 'f':
  98.     case 'F': ScreenToFront(MainScreen);
  99.           break;
  100.  
  101.     case 'm':
  102.     case 'M': MainScreen->TopEdge=0;
  103.           MainScreen->ViewPort.DyOffset=0;
  104.           Screen->TopEdge=57;
  105.           Screen->ViewPort.DyOffset=57;
  106.           ScreenToFront(Screen);
  107.           RemakeDisplay();
  108.           break;
  109.  
  110.     case 'n':
  111.     case 'N': MainScreen->TopEdge=NormalRows-56;
  112.           MainScreen->ViewPort.DyOffset=NormalRows-56;
  113.           Screen->TopEdge=0;
  114.           Screen->ViewPort.DyOffset=0;
  115.           ScreenToFront(MainScreen);
  116.           RemakeDisplay();
  117.           break;
  118.  
  119.     default: break;
  120.     }
  121. }
  122.  
  123. holdit(message)
  124. struct IntuiMessage *message;
  125. {
  126. struct Gadget *igad;
  127. int gadgid,hiexit=0;
  128. ULONG class;
  129.  
  130. igad=(struct Gadget *) message->IAddress;
  131. gadgid=igad->GadgetID;
  132.  
  133. if (copy==1 || swap==1) {
  134.     ClearPointer(Window);
  135.     copy=swap=0;
  136.     }                 /* turn off special modes */
  137.  
  138. if (overscan) return();
  139.  
  140. do {
  141.     message=(struct IntuiMessage *) GetMsg(Window->UserPort);
  142.     if (message != NULL) {
  143.         class=message->Class;
  144.         ReplyMsg(message);
  145.         if (class==GADGETUP) hiexit=1;
  146.         }
  147.     switch (gadgid) {    
  148.         case 1: offset-=width;
  149.             if (offset < lower[type]) offset=lower[type];
  150.             redo();
  151.             break;
  152.  
  153.         case 2: offset++;
  154.             if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
  155.             redo();
  156.             break;
  157.  
  158.         case 3: offset+=width;
  159.             if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
  160.             redo();
  161.             break;
  162.  
  163.         case 4: offset--;
  164.             if (offset < lower[type]) offset=lower[type];
  165.             redo();
  166.             break;
  167.  
  168.         case 45: redoprop();
  169.              break;
  170.  
  171.         default: break;
  172.         }
  173.     } while (hiexit==0);
  174. }
  175.  
  176. option(message)
  177. struct IntuiMessage *message;
  178. {
  179. struct Gadget *igad;
  180. int gadgid;
  181. long temp;
  182. ULONG size,max;
  183.  
  184. igad=(struct Gadet *) message->IAddress;
  185. gadgid=igad->GadgetID;
  186.  
  187. switch(gadgid) {
  188.     case 1: if (overscan) doscan(1);
  189.         else {
  190.         offset-=width/(7*fine+1);
  191.         if (offset < lower[type]) offset=lower[type];
  192.         redo();
  193.         }
  194.         break;
  195.  
  196.     case 2: if (overscan) doscan(2);
  197.         else {
  198.         offset++;
  199.         if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
  200.         redo();
  201.         }
  202.         break;
  203.  
  204.     case 3: if (overscan) doscan(3);
  205.         else {
  206.         offset+=width/(7*fine+1);
  207.         if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
  208.         redo();
  209.         }
  210.         break;
  211.  
  212.     case 4: if (overscan) doscan(4);
  213.         else {
  214.         offset--;
  215.         if (offset < lower[type]) offset=lower[type];
  216.         redo();
  217.         }
  218.         break;
  219.  
  220.     case 5: num_bitplanes++;
  221.         if (num_bitplanes > 6) num_bitplanes=6;
  222.         if (type==FAST) {
  223.             PlanePtr[num_bitplanes-1]=AllocRaster(width,height);
  224.             if (PlanePtr[num_bitplanes-1]) {
  225.                 CopyMem(lower[FAST],PlanePtr[num_bitplanes-1],(width/8)*height);
  226.                 bm.Planes[num_bitplanes-1]=PlanePtr[num_bitplanes-1];
  227.                 Screen->RastPort.BitMap->Planes[num_bitplanes-1]=PlanePtr[num_bitplanes-1];            /* if not, couldn't allocate the chip memory */
  228.                 }
  229.             else num_bitplanes--;
  230.             }
  231.         set_depth();
  232.         break;
  233.  
  234.     case 6: num_bitplanes--;
  235.         if (num_bitplanes < 1) num_bitplanes=1;
  236.         if (type==FAST) {
  237.             if (PlanePtr[num_bitplanes]) FreeRaster(PlanePtr[num_bitplanes],width,height);
  238.             PlanePtr[num_bitplanes]=0;
  239.             }
  240.         set_depth();
  241.         if (plane >= num_bitplanes) {
  242.             show_plane(1,2);
  243.             plane=num_bitplanes-1;
  244.             show_plane(2,1);
  245.             }
  246.         break;
  247.  
  248.     case 7: offset=atoi(Gadget32SIBuff);
  249.         if (offset < lower[type]) offset=lower[type];
  250.         if (offset+width/8*height > upper[type]) offset=upper[type]-width/8*height;
  251.         redo();
  252.         calcpropgad();
  253.         break;
  254.  
  255.     case 9: if (Gadget6.Flags & SELECTED)
  256.             fine=1;
  257.         else fine=0;
  258.         break;   
  259.  
  260.     case 10: if (Gadget13.Flags & SELECTED) {
  261.             if (type==FAST) freefastmem();
  262.             Screen->ViewPort.Modes |= LACE;
  263.             Screen->RastPort.BitMap->Rows=NormalRows*2;
  264.             bm.Rows=NormalRows*2;        
  265.             Screen->Height=NormalRows*2;
  266.             Screen->ViewPort.DHeight=NormalRows*2;
  267.             height=NormalRows*2;
  268.             if (type==FAST) allocfastmem();
  269.             }
  270.          else {
  271.             if (type==FAST) freefastmem();
  272.             Screen->ViewPort.Modes &= ~LACE;
  273.             Screen->RastPort.BitMap->Rows=NormalRows;
  274.             bm.Rows=NormalRows;
  275.             Screen->Height=NormalRows;
  276.             Screen->ViewPort.DHeight=NormalRows;
  277.             height=NormalRows;
  278.             if (type==FAST) allocfastmem();
  279.             }
  280.          calcpropgad();
  281.          fixhwgads();
  282.          RemakeDisplay();
  283.          break;
  284.  
  285.     case 11: if (Gadget14.Flags & SELECTED) {
  286.             if (type==FAST) freefastmem();
  287.             Screen->ViewPort.Modes |= HIRES;
  288.             Screen->Width=640;
  289.             Screen->RastPort.BitMap->BytesPerRow=80;
  290.             bm.BytesPerRow=80;    /* 640 div 8 */
  291.             Screen->ViewPort.DWidth=640;
  292.             width=640;
  293.             if (type==FAST) allocfastmem();
  294.             }
  295.          else {
  296.             if (type==FAST) freefastmem();
  297.             Screen->ViewPort.Modes &= ~HIRES;
  298.             Screen->Width=320;
  299.             bm.BytesPerRow=40;   /* 320 div 8 */
  300.             Screen->RastPort.BitMap->BytesPerRow=40;
  301.             Screen->ViewPort.DWidth=320;
  302.             width=320;
  303.             if (type==FAST) allocfastmem();
  304.             }
  305.          calcpropgad();
  306.          fixhwgads();
  307.          RemakeDisplay();
  308.          break;
  309.  
  310.     case 12: if (Gadget15.Flags & SELECTED) {
  311.             Screen->ViewPort.Modes |= EXTRA_HALFBRITE;
  312.             if (num_bitplanes < 6) Message("WARNING: Should have 6 bitplanes.");
  313.             }
  314.          else
  315.             Screen->ViewPort.Modes &= ~EXTRA_HALFBRITE;
  316.          RemakeDisplay();
  317.          break;
  318.  
  319.     case 13: if (Gadget16.Flags & SELECTED) {
  320.             Screen->ViewPort.Modes |= HAM;
  321.             if (num_bitplanes < 6) Message("WARNING: Should have 6 bitplanes.");
  322.             }
  323.          else
  324.             Screen->ViewPort.Modes &= ~HAM;
  325.          RemakeDisplay();
  326.          break;
  327.  
  328.     case 20:
  329.     case 21:
  330.     case 22:
  331.     case 23:
  332.     case 24:
  333.     case 25: if (gadgid-19 > num_bitplanes) break;
  334.          if (type==FAST) FOffset[plane]=offset;
  335.          if (copy==1) {
  336.             bm.Planes[gadgid-20]=Screen->RastPort.BitMap->Planes[gadgid-20]=bm.Planes[plane];
  337.             copy=0;
  338.             ClearPointer(Window);
  339.             RemakeDisplay();
  340.             }
  341.          if (swap==1) {
  342.             temp